package com.lazar.dao;

import com.lazar.model.Admin;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class AdminDao {
   public Admin getAdmin(String name){
       Admin admin = new Admin();
       Connection conn = DbHelper.getConn();

       String sql = "select * from t_admin where `name` = '"+ name +"'";

       try {
           PreparedStatement pt = conn.prepareStatement(sql);
           ResultSet rs = pt.executeQuery();

           while (rs.next()){
               admin.setUid(rs.getInt("uid"));
               admin.setName(rs.getString("name"));
               admin.setPass(rs.getString("pass"));
               break;
           }
       } catch (SQLException e) {
           e.printStackTrace();
       }

       return admin;
   }
}
